#Matthew Bell - Game Tools Development - GP 3310

import sys


#PRIME STUFF STARTS NAAAAAAOOOOOOWWW

def Primes(upTo):
    d = [2, 3]
    for prime in range(5, upTo, 2):
        isDivis = False
        for check in d:
            if (prime % check) == 0:
                isDivis = True
            elif (check * check > prime):
                break
        if(isDivis == False):
            d.append(prime)

    last = 0
    largest = 0
    for anotherVariable in d:
        print 'Prime: ' + str(anotherVariable) + ' '
        diff = anotherVariable - last
        if( diff > largest):
            largest = diff
        last = anotherVariable
    print 'largest difference between primes: ' + str(largest)

print 'Input primes to check: '
inp = input()
while(inp != 'q'):
    Primes(inp)
    inp = input()
